/**
 * LoadingService
 * 用于控制全局Loading的显示和隐藏
 */

class LoadingService {
  /**
   * 显示全局loading
   */
  static showLoading() {
    if (
      typeof window !== "undefined" &&
      (window as any).GlobalLoadingNamespace &&
      (window as any).GlobalLoadingNamespace.show
    ) {
      (window as any).GlobalLoadingNamespace.show();
    } else {
      console.warn("GlobalLoading component not initialized yet");
    }
  }

  /**
   * 隐藏全局loading
   */
  static hideLoading() {
    if (
      typeof window !== "undefined" &&
      (window as any).GlobalLoadingNamespace &&
      (window as any).GlobalLoadingNamespace.hide
    ) {
      (window as any).GlobalLoadingNamespace.hide();
    } else {
      console.warn("GlobalLoading component not initialized yet");
    }
  }
}

export default LoadingService;
